package com.ltmall.api.enums;

/**
 * 用户身份枚举类
 *
 * @author dou.guo
 * @Title MembershipEnum.java
 * @Description 类MembershipEnum.java的实现描述：类实现描述 
 * @date 2017年9月26日 下午4:52:09
 * @package com.wuwangkeji.homeflavor.enums
 */
public enum MembershipEnum {

    /**普通会员*/
    PUBLIC_MEMBER("0", "普通会员"),

    /**黄金会员*/
    GOLD_MEMBER("1", "黄金会员"),

    /**钻石会员*/
    DIAMOND_MEMBER("2", "钻石会员"),

    /**皇冠会员*/
    CROWN_MEMBER("3", "皇冠会员"),

    /**董事特权用户*/
    PRIVILEGE_MEMBER("8", "董事特权用户"), ;

    private String code;
    private String name;

    private MembershipEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static MembershipEnum getEnumByCode(String code) {
        if (code == null) {
            return null;
        }
        MembershipEnum[] arr = MembershipEnum.values();
        for (MembershipEnum e : arr) {
            if (e.code.equals(code)) {
                return e;
            }
        }
        return null;

    }

    public static MembershipEnum getEnumByName(String name) {
        if (name == null) {
            return null;
        }
        MembershipEnum[] arr = MembershipEnum.values();
        for (MembershipEnum e : arr) {
            if (e.name.equals(name)) {
                return e;
            }
        }
        return null;

    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

}
